# coding=utf-8
import re

# 限定符 *、+、? 的使用
# * 匹配0次或多次
partten = "\d*"
str = "123abc"
# str = "abc"   # re.Match object; span=(0, 0), match=''>
print(re.match(partten, str))
# + 匹配1次或多次
partten = "\d+"
str = "123abc"
# str = "abc"   # None
print(re.match(partten, str))
# ? 匹配1次或0次
partten = "\d?"
str = "123abc"
# str = "abc"   # re.Match object; span=(0, 0), match=''>
print(re.match(partten, str))
# {m} 重复m次
partten = "\d{3}"
str = "1234abc"
print(re.match(partten, str))
# {m,n} 重复m到n次
partten = "\d{3,5}"
str = "1234abc"
print(re.match(partten, str))
# {m,} 重复至少m次
partten = "\d{3,}"
str = "123456abc"
print(re.match(partten, str))
